<template>
  <div class="detail-container">
    <!-- 详情页上面 -->
    <div class="detail-container-top">
      <!-- 图片 -->
      <div class="detail-container-img">
        <img :src=" food.imgUrl"/>
      </div>
      <div class="goback" @click="goback()"><van-icon name="down" /></div>
      <!-- 信息 -->
      <div class="detail-container-info">
        <div class="detail-container-info-left">
          <h2>{{food.category}}</h2>
          <p class="info-left-sell-all">
            <span class="info-left-sell">月售{{food.sellCount}}份</span> <span>好评率{{food.rating}}%</span>
          </p>
          <p>
            <span class="info-left-price-new">&yen;{{food.price}}</span> <s>&yen;{{food.price}}</s>
          </p>
        </div>
        <label >数量:{{ food.num }}</label>
        <h3>
          <span><van-icon name="cart-circle-o" class="addShop"/></span> 加入购物车
        </h3>
      </div>
    </div>
    <!-- 详情页下面 商品介绍 -->
    <div class="detail-container-botton">
      <h2>介绍</h2>
      <p>{{food.goodsDesc}}</p>
    </div>
  </div>
</template>

<script lang="ts">
import { Component, Vue } from "vue-property-decorator";

@Component
export default class extends Vue {
/*     category: "好吃"
ctime: "2022-03-19T12:48:49.000Z"
goodsDesc: "11"
id: "131"
imgUrl: "http://127.0.0.1:5000/imgs/1647694127242.jpg"
name: "11"
price: "2"
rating: "100"
ratings: Array(3)
sellCount: "180" */

    //数据
    food:any={}
    //生命周期
    created(){
        this.food= this.$route.query
        console.log(this.food);
        
    }
    //点击事件,返回shop页面
    goback(){
      this.$router.push('/home/shop')
    }
}
</script>

<style lang="scss" scoped>
@import '../../assets/styles/theme.scss';
// $active: rgb(178, 13, 31);
.detail-container {
  width: 100%;
  height: 100%;
  background-color: rgb(244, 245, 247);
  display: flex;
  flex-direction: column;
  .detail-container-top {
    width: 100%;
    height: 350px;
    background-color: #fff;
    display: flex;
    flex-direction: column;
    margin-bottom: 20px;
    position: relative;
     .goback{
        position: absolute;
        top: 10px;
        left: 20px;
        width: 24px;
        text-align: center;
        line-height: 24px;
        border: 1px solid #000;
        border-radius: 50%;
      }
    .detail-container-img {
      width: 100%;
      height: 200px;
      img {
        width: 100%;
        height: 200px;
      }
    }
    .detail-container-info {
      padding: 20px;
      flex: 1;
      background-color: #fff;
      margin-bottom: 20px;
      position: relative;
      h3 {
        // border: 1px;
        width: 120px;
        line-height: 40px;
        border-radius: 15px;
        text-align: center;
        background-color: $active ;
        position: absolute;
        right: 20px;
        color: #fff;
        bottom: 20px;
        .addShop{
            font-weight:bold ;
        }
      }
      .detail-container-info-left {
        color: rgb(174, 174, 174);

        h2 {
          color: #000;
          font-size: 18px;
        }
        .info-left-sell-all {
          margin: 10px 0;
          .info-left-sell {
            margin-right: 10px;
          }
        }
        .info-left-price-new {
          color: red;
          font-size: 20px;
          font-weight: bold;
          margin-right: 10px;
        }
      }
    }
  }
  .detail-container-botton {
    background-color: #fff;
    width: 100%;
    flex: 1;
    padding: 20px;
    h2{
        font-size: 20px;
        color: #000;
        margin-bottom: 20px;
    }
    p{
        line-height: 18px;
    }
  }
}
</style>